﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class IntervalVariableExpressionElement : VariableExpressionElement
    {
        private ExpressionElement start;
        private ExpressionElement end;

        public ExpressionElement Start { get { return start; } set { start = value; } }
        public ExpressionElement End { get { return end; } set { end = value; } }

        public IntervalVariableExpressionElement(TokenInfo StartInfo, ExpressionElement Start, ExpressionElement End, List<TokenInfo> Comments)
            : base(StartInfo, Comments)
        {
            start = Start;
            end = End;
        }

        public override string ToString()
        {
            if (end != null)
                return string.Format("{0}..{1}", start, end);
            else return start.ToString();
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            yield return start;
            if (end != null) yield return end;
        }
    }
}
